[WIP] SetIsOriginAllowedToAllowWildcardSubdomains requires base origin instead of wildcard #36164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Issue: The documentation incorrectly showed using
"https://*.example.com"withSetIsOriginAllowedToAllowWildcardSubdomains(). The correct usage requires the base origin without the wildcard (e.g.,"https://example.com"). The method itself handles the wildcard subdomain matching internally.Root Cause: When
SetIsOriginAllowedToAllowWildcardSubdomains()is called, it internally adds logic to match wildcard subdomains. Passing"https://*.example.com"toWithOrigins()would attempt to literally match an origin with an asterisk in it, which is not valid. Instead, you pass the base domain"https://example.com"and the method handles matching"https://subdomain.example.com","https://api.example.com", etc.Changes Made
Code Samples (4 files):
All changed from
"https://*.example.com"to"https://example.com"when used withSetIsOriginAllowedToAllowWildcardSubdomains().Documentation (3 files):
Added explanatory text: "In the preceding code,
SetIsOriginAllowedToAllowWildcardSubdomainsis called with the base origin"https://example.com". This configuration allows CORS requests from any subdomain ofexample.com, such ashttps://subdomain.example.comorhttps://api.example.com. The wildcard matching is handled by the method, so the origin should be specified without the*wildcard character."Validation:
SetIsOriginAllowedToAllowWildcardSubdomains()now use base origins without wildcardsSetIsOriginAllowedToAllowWildcardSubdomains()(e.g., withAllowAnyHeader(),WithExposedHeaders()) correctly retain the wildcard pattern"https://*.example.com"Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Internal previews